# 某个班list1 要分组, 每组分几个人不确定   x , 可以分几组
# 第 m 组成员有哪些
# 第 m 组是不是最后一组


class Group:
    def __init__(self, obj_list, per_page):
        self.obj_list = obj_list
        self.per_page = per_page

    def max_group_count(self):
        if len(self.obj_list) % self.per_page:
            group_count = len(self.obj_list) // self.per_page + 1
        else:
            group_count = len(self.obj_list) // self.per_page
        return group_count

    def get_group(self, m):
        if m > self.max_group_count():
            m = self.max_group_count()
            # raise Exception("别乱搞!")
        return self.obj_list[(m - 1) * self.per_page:m * self.per_page]

    def islastgroup(self, m):
        return m >= self.max_group_count()
        # return  not m < self.max_group_count()


if __name__ == '__main__':
    list1 = [x for x in range(1, 30)]
    g = Group(list1, 5)
    print(g.max_group_count())
    print(g.get_group(9))
    print(g.islastgroup(4))
    print(g.islastgroup(5))
